package com.wxy.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.wxy.domain.user;
import com.wxy.domain.user2;
import com.wxy.service.service;

import jakarta.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/boot1")
public class MyController {
	@Autowired
	private service service;
	@RequestMapping("test1")
	@ResponseBody
	public String test1(HttpServletRequest request) {
		String jsonString=request.getParameter("data");
		System.out.println(jsonString);
		if(jsonString!=null)
			return "OK";
		else {
			return "不OK";
		}
	}
	@RequestMapping("/test2/{id}")				//添加缓存策略
	@ResponseBody
	public user2 test2(@PathVariable(value = "id") int id) {
		return service.getUserById2(id);
	}
	@RequestMapping("test3/{id}/{username}")	//缓存更新策略
	@ResponseBody
	public boolean test3(@PathVariable(value = "id")int id ,@PathVariable(value = "username")String username) {
		return service.updateById(id,username);
	}
	@RequestMapping("/test4/{id}")
	@ResponseBody
	public user2 test4(@PathVariable(value = "id") int id) {
		return service.findById(id);
	}
	@RequestMapping("/test5/{id}")
	@ResponseBody
	public user2 test5(@PathVariable(value = "id") int id) {
		return service.findById2(id);
	}
}
